(function () {
    function TimerReadyUI() {
        TimerReadyUI.super(this);

        this._timeout = null;

        this.y       = 873;
        this.name    = "TimerReady";
        this.visible = false;
    }
    Laya.class(TimerReadyUI, "ui.Com.TimerReady", ui.Room.UI.TimerReadyUI);

    var _proto = TimerReadyUI.prototype;
    /**
     * @privite
     * 计算倒计时时间并更新界面
     */
    _proto.onCountDown = function () {
        var timeout = this._timeout;

        timeout = timeout <= 0 ? 0 : timeout;
        timeout = timeout < 10 ? "0" + timeout : timeout;

        this.time.changeText(timeout);

        timeout--;
        this._timeout = timeout;
    }
    /**
     * @public
     * 准备计时器开始倒计时
     * 
     * @param {Number} timeout 倒计时开始时间
     */
    _proto.start = function (timeout) {
        utils.log("====-------TimerReady.CountDown-------=====");
        utils.log("剩余时间：" + timeout);

        this._timeout = timeout;
        this.visible  = true;

        this.onCountDown();
        Laya.timer.loop(1000, this, this.onCountDown);
    }
    /**
     * @public
     * 准备计时器结束倒计时
     */
    _proto.stop = function () {
        utils.log("====-------TimerReady.Stop-------=====");
        utils.log("剩余时间：" + this._timeout);
        
        this._timeout = null;
        this.visible  = false;

        Laya.timer.clear(this, this.onCountDown);
    }
})();